package kr.hkit.androidcomplete02.service;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Messenger;
import android.widget.Toast;

public class MessengerService extends Service {

	static final int MSG_SAY_HELLO=1;	
	static final int MSG_SAY_HI=2;
	
	Messenger mMessenger = new Messenger(new Handler(){
		public void handleMessage(android.os.Message msg) {
			switch(msg.what){
			case MSG_SAY_HELLO:
				Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_LONG).show();
				break;
			case MSG_SAY_HI:
				Toast.makeText(getApplicationContext(), "Hi", Toast.LENGTH_LONG).show();
				break;
			default:
				super.handleMessage(msg);
			}
		};
	});
	
	@Override
	public IBinder onBind(Intent intent) {
		Toast.makeText(getApplicationContext(), "binding....", Toast.LENGTH_LONG).show();
		return mMessenger.getBinder();
	}

}
